package com.yc.ssm.util;

import java.util.Map;

/**
 * 字符串处理工具类
 * @author asus
 */
public class StringUtil {
	/**
	 * 判空处理
	 * @param strs
	 * @return
	 */
	public static boolean checkNull(String ... strs) {
		if(strs == null || strs.length <= 0) {
			return true;
		}
		
		for(String str : strs) {
			if(str == null || "".equals(str)) {
				return true;
			}
		}
		return false;
	}
	
	/**
	 * 判空处理
	 * @param strs
	 * @return
	 */
	public static boolean checkNull(Object ... objs) {
		if(objs == null || objs.length <= 0) {
			return true;
		}
		
		for(Object obj : objs) {
			if(obj == null || "".equals(obj)) {
				return true;
			}
		}
		return false;
	}
	
	public static Map<String,Object> findByPageUtil(Map<String,Object> map){
		int page = 2;
		Object temp = map.get("page");
		if(temp != null && !"".equals(String.valueOf(temp))) {
			page = Integer.parseInt(String.valueOf(temp));
		}
		
		int rows = 10;
		temp = map.get("rows");
		if(temp != null && !"".equals(String.valueOf(temp))) {
			rows = Integer.parseInt(String.valueOf(temp));
		}
		map.put("page", (page-1) * rows);
		map.put("rows", rows);
		
		return map;
	}
	
	public static Map<String,Object> findByPageUtil2(Map<String,Object> map){
		int page = 2;
		Object temp = map.get("page");
		if(temp != null && !"".equals(String.valueOf(temp))) {
			page = Integer.parseInt(String.valueOf(temp));
		}
		
		int limit = 10;
		temp = map.get("limit");
		if(temp != null && !"".equals(String.valueOf(temp))) {
			limit = Integer.parseInt(String.valueOf(temp));
		}
		map.put("page", (page-1) * limit);
		map.put("limit", limit);
		
		return map;
	}
}
